package com.health.model;

import java.util.Date;

import org.springframework.beans.BeanUtils;

import com.health.dto.BaseDTO;
import com.health.dto.UserDTO;

/**
 * UserEntity include "permission","status"
 */
public class User extends BasePO
{
	private String	id;
	private String	name;
	private String	password;
	private String	email;			// unique
	private Integer	gender;		// 0:male 1:female
	private Date	birthdate;		//
	private Date	registertime;	// exact to second
	private Integer	permission;	// 0:admin 1:normal user
	private Integer	status;	// 0:normal 1:forbidden--number bigger is more
	// guilty
	private Integer	loginCount;	// how much times login failed, to record the
	// times
	private Date	startBirthdate; // time scope fro query
	private Date	endBirthdate;	// time scope fro query

	// be used to paging
	private Integer	start;
	private Integer	limit;

	/**
	 * constructors
	 */
	public User()
	{}

	public User(String id, String name, String password, Integer gender,
			String email, Date birthdate, Date registertime,
			Integer permission, Integer status)
	{
		this.id = id;
		this.name = name;
		this.password = password;
		this.gender = gender;
		this.email = email;
		this.birthdate = birthdate;
		this.registertime = registertime;
		this.permission = permission;
		this.status = status;
	}

	
	@Override
	public BaseDTO convertPOToDTO(BasePO po)
	{
		UserDTO dto = new UserDTO();
		BeanUtils.copyProperties(po, dto);
		return dto;
	}
	
	@Override
	public String toString()
	{
		return this.id + " " + name + " " + password + " " + gender + " "
				+ birthdate.toString() + " " + registertime.toString() + " "
				+ permission + " " + status;
	}

	/**
	 * getters and setters
	 */
	public String getId()
	{
		return id;
	}

	public void setId(String id)
	{
		this.id = id;
	}

	public String getName()
	{
		return name;
	}

	public void setName(String name)
	{
		this.name = name;
	}

	public String getPassword()
	{
		return password;
	}

	public void setPassword(String password)
	{
		this.password = password;
	}

	public String getEmail()
	{
		return email;
	}

	public void setEmail(String email)
	{
		this.email = email;
	}

	public Integer getGender()
	{
		return gender;
	}

	public void setGender(Integer gender)
	{
		this.gender = gender;
	}

	public Date getBirthdate()
	{
		return birthdate;
	}

	public void setBirthdate(Date birthdate)
	{
		this.birthdate = birthdate;
	}

	public Date getRegistertime()
	{
		return registertime;
	}

	public void setRegistertime(Date registertime)
	{
		this.registertime = registertime;
	}

	public Integer getPermission()
	{
		return permission;
	}

	public void setPermission(Integer permission)
	{
		this.permission = permission;
	}

	public Integer getStatus()
	{
		return status;
	}

	public void setStatus(Integer status)
	{
		this.status = status;
	}

	public Date getStartBirthdate()
	{
		return startBirthdate;
	}

	public void setStartBirthdate(Date startBirthdate)
	{
		this.startBirthdate = startBirthdate;
	}

	public Date getEndBirthdate()
	{
		return endBirthdate;
	}

	public void setEndBirthdate(Date endBirthdate)
	{
		this.endBirthdate = endBirthdate;
	}

	public Integer getStart()
	{
		return start;
	}

	public void setStart(Integer start)
	{
		this.start = start;
	}

	public Integer getLimit()
	{
		return limit;
	}

	public void setLimit(Integer limit)
	{
		this.limit = limit;
	}

	public Integer getLoginCount()
	{
		return loginCount;
	}

	public void setLoginCount(Integer loginCount)
	{
		this.loginCount = loginCount;
	}



}
